const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const axios = require('./ipc/interceptors');

// ... existing code ...

// 监听来自渲染进程的请求
ipcMain.handle('http-request', async (event, { method, url, data }) => {
  try {
    const response = await axios({
      method,
      url,
      data
    });
    return { success: true, data: response.data };
  } catch (error) {
    return { success: false, error: error.message };
  }
});

// 监听认证错误事件
ipcMain.on('auth-error', (event, { type, message }) => {
  // 发送消息给渲染进程
  event.sender.send('auth-error', { type, message });
});

// ... existing code ...